﻿#ifndef COMMONPAGE_H
#define COMMONPAGE_H

#include <QWidget>
#include "musiclist.h"
#include "music.h"
#include <QMediaPlaylist>

namespace Ui {
class CommonPage;
}

// 区分不同page⻚⾯
enum PageType
{
    LIKE_PAGE, // 我喜欢⻚⾯
    LOCAL_PAGE, // 本地下载⻚⾯
    HISTORY_PAGE // 最近播放⻚⾯
};

class CommonPage : public QWidget
{
    Q_OBJECT

public:
    explicit CommonPage(QWidget *parent = 0);
    ~CommonPage();

    void setCommonPageUI(const QString& title,const QString& imagePath);

    void setMusicListType(PageType pageType);

    void addMusicToMusicPage(MusicList& musicList);

    void reFresh(MusicList& musicList);

    void addMusicToMediaplayList(MusicList& musicList,QMediaPlaylist* playList);

    void setMusicImage(QPixmap pixmap);

    const QString& getMusicIdByIndex(int index);


signals:
    void updateLikeMusic(bool isLike,QString musicId);

    void playAll(PageType pageType);

    void playMusicByIndex(CommonPage* ,int );
private:
    Ui::CommonPage *ui;

    PageType pageType;//页面类别

    QVector<QString> musicListOfPage; // 具体某个⻚⾯的⾳乐，将来只需要存储⾳乐的id即可
};

#endif // COMMONPAGE_H
